import requests;
def getHTMLText(url):
    try:
        r=requests.get(url, timeout=30)
        print(r.status_code)
        r.raise_for_states()
        r.encoding=r.apparent_encoding
        return r.text
    except:
        return "产生异常"
if __name__=="__main__":
    url='https://tieba.baidu.com/p/7019582042'
    print(getHTMLText(url))



